Chapter 2 Electricity profiles
This chapter provides electricity profiles and a R coding technique. Electricity profiles are illustrated to give an insight into profile behavior. R coding technique are given in order to understand the process flow and manage the big data obtained from several sources in the organization.
2.1 Initial settings
Before the project starts, packages are required as follows:
- A
tidyversepackage is a bunch of packages to handle with a data analysis (for more information click here). It consists of data manipulation and visualization as follows:- A
ggplot2package is for data visualization. - A
dplyrpackage is for data manipulation. - A
tidyrpackage is for data tidying. - A
readrpackage is for data import. - A
purrrpackage is for functional programming. - A
tibblepackage is a modern reimagining of the data.frame. - A
stringrpackage is for strings. - A
forcatspackage is for factors. - A
lubridatepackage is for date and time.
- A
- A
readxlpackage is used for read data from Excel into R. - A
scalespackage is applied to scale plots in the ggplot2 package. - A
gluepackage interprets strings literal. The package embeds R expressions and inserts into argument string. - A
knitrpackage is a lightweight API’s designed to give users full control of the output without heavy coding work. In this project, the package is used for making a HTML.
library(tidyverse) #For data manipulation
library(readxl) #For reading the excel sheet
library(scales)
library(glue)
library(knitr)
library(plotly)Theme and lines for figures are set in a variable named Themeline as follows:
theme_bw()function provides a black and white theme.theme()function applied for setting theme and line represented in plots.linepalette1andlinepalette1variables set line colors.
ThemeLine <-
theme_bw() +
theme(
panel.border=element_rect(fill=NA),
panel.grid.minor = element_line(color = NA),
# axis.title=element_text(size=5),
# axis.text.x = element_text(hjust=1,size = 10, angle = 0),
axis.line=element_line(colour="black"),
panel.background=element_rect(fill = "white"),
panel.grid.major.x=element_line(linetype="dashed",colour="grey",linewidth = 0.5),
panel.grid.major.y = element_blank(),
# panel.grid.major=element_blank(),
strip.background=element_rect(fill="white", colour="white"),
strip.text.x = element_text(size=10, colour = "black", angle = 0,face="bold"),
axis.text.x=element_text(size = 10,angle=45, vjust=0.9, hjust=1, margin = unit(c(t = 0.3, r = 0, b = 0, l = 0), "cm")),
axis.text.y=element_text(size = 10,margin = unit(c(t = 0, r = 0.3, b = 0, l = 0), "cm")),
legend.text = element_text(size = 10),
legend.title = element_text(size = 10),
axis.ticks.length=unit(-0.15,"cm")
)
linepalette1 <- c("#4DAF4A","#FF7F00","#377EB8","#E41A1C","#984EA3","#F781BF","#8DD3C7","#FB8072","#80B1D3","#FDB462","#B3DE69","#FCCDE5","#D9D9D9","#BC80BD","#CCEBC5","#FFED6F","#7f878f","#A65628","#FFFF33")
linepalette2 <- c("#E41A1C","#FF7F00","#377EB8","#B3DE69","#4DAF4A","#984EA3","#F781BF","#8DD3C7","#FB8072","#80B1D3","#FDB462","#FCCDE5","#D9D9D9","#BC80BD","#CCEBC5","#FFED6F","#7f878f","#A65628","#FFFF33")Lists are create to store variables.
2.2 The EGAT electrity sale profiles
2.2.3 The 2019 Direct Customer (DC) EGAT sale profiles
2.2.3.1 The 2019 DC in in PEA R1 (Central region) EGAT sale profiles
# Profile data ####
profile <-
read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
sheet = "Load Curve",
range = "C3:J17523"
) %>%
select(datetime = `Date/Time`, DCs_R1) %>%
mutate(date = date(datetime),
time = format(as.POSIXct(datetime),"%H:%M:%S"),
year = year(datetime),
month = month(datetime),
day = day(datetime)) %>%
select(datetime, date, time, year, month, day, DCs_R1) #%>% | datetime | date | time | year | month | day | DCs_R1 |
|---|---|---|---|---|---|---|
| 2019-01-01 00:00:00 | 2019-01-01 | 00:00:00 | 2019 | 1 | 1 | 201.253 |
| 2019-01-01 00:30:00 | 2019-01-01 | 00:30:00 | 2019 | 1 | 1 | 202.469 |
| 2019-01-01 01:00:00 | 2019-01-01 | 01:00:00 | 2019 | 1 | 1 | 190.028 |
| 2019-01-01 01:30:00 | 2019-01-01 | 01:30:00 | 2019 | 1 | 1 | 196.300 |
| 2019-01-01 02:00:00 | 2019-01-01 | 02:00:00 | 2019 | 1 | 1 | 177.956 |
| peak_day | min_day | peak_mw | min_mw | energy_gwh | load_factor |
|---|---|---|---|---|---|
| 2019-03-23 05:30:00 | 2019-09-11 13:00:00 | 421 | 81 | 2006.585 | 54.41% |
# Plot a profile ####
profile_plot <-
ggplot() +
geom_line(data=profile,
aes(x = datetime,
y = DCs_R1,
group = month,
color = as.factor(month)),
show.legend = FALSE) +
ThemeLine +
labs(x = NULL,
y = "EGAT sale to direct customers in PEA R1 (Central region) (MW)")+
scale_x_datetime(breaks=date_breaks("1 month"),
labels=date_format("%b %y")) +
scale_y_continuous(breaks = seq(0, round(maxv,-2)*1.2,100),
limits = c(0, round(maxv, -2)*1.2)) +
scale_color_manual(values = linepalette1) +
geom_point(data=summary,
aes(x = peak_day, y = peak_mw))+
geom_text(data = summary,
aes(x = peak_day, y = round(maxv, -2)*1.2),
label = glue("Peak {maxv} MW \n@ {peak_day}"))+
geom_point(data=summary,
aes(x = min_day, y = min_mw))+
geom_text(data = summary,
aes(x = min_day, y = round(minv, -2)),
label = glue("Minimum {minv} MW \n@ {min_day}"),
hjust = 0,
vjust = 1.5)
# Save the output ####
outputfigure <- paste0(outfigdir, "dc_r1_central_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("dc_r1_central_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("dc_r1_central_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_dc_r1_central_egtsle_2019" = summary))The 2019 electricity sale profile from EGAT to direct customer in PEA-R1 is illustrated in Figure 2.7).
Figure 2.7: EGAT electricity sale profile to direct customer in PEA-R1 in 2019.
2.2.3.2 The 2019 DC in in PEA R2 (North Eastern region) EGAT sale profiles
# Profile data ####
profile <-
read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
sheet = "Load Curve",
range = "C3:K17523"
) %>%
select(datetime = `Date/Time`, DCs_R2) %>%
mutate(date = date(datetime),
time = format(as.POSIXct(datetime),"%H:%M:%S"),
year = year(datetime),
month = month(datetime),
day = day(datetime)) %>%
select(datetime, date, time, year, month, day, DCs_R2) #%>% | datetime | date | time | year | month | day | DCs_R2 |
|---|---|---|---|---|---|---|
| 2019-01-01 00:00:00 | 2019-01-01 | 00:00:00 | 2019 | 1 | 1 | 45.91 |
| 2019-01-01 00:30:00 | 2019-01-01 | 00:30:00 | 2019 | 1 | 1 | 74.97 |
| 2019-01-01 01:00:00 | 2019-01-01 | 01:00:00 | 2019 | 1 | 1 | 72.34 |
| 2019-01-01 01:30:00 | 2019-01-01 | 01:30:00 | 2019 | 1 | 1 | 70.17 |
| 2019-01-01 02:00:00 | 2019-01-01 | 02:00:00 | 2019 | 1 | 1 | 68.94 |
| peak_day | min_day | peak_mw | min_mw | energy_gwh | load_factor |
|---|---|---|---|---|---|
| 2019-05-20 22:30:00 | 2019-09-17 07:30:00 | 609 | 0 | 1300.891 | 24.38% |
# Plot a profile ####
profile_plot <-
ggplot() +
geom_line(data=profile,
aes(x = datetime,
y = DCs_R2,
group = month,
color = as.factor(month)),
show.legend = FALSE) +
ThemeLine +
labs(x = NULL,
y = "EGAT sale to direct customers in PEA R2 (North Eastern region) (MW)")+
scale_x_datetime(breaks=date_breaks("1 month"),
labels=date_format("%b %y")) +
scale_y_continuous(breaks = seq(0, round(maxv,-2)*1.2,100),
limits = c(0, round(maxv, -2)*1.2)) +
scale_color_manual(values = linepalette1) +
geom_point(data=summary,
aes(x = peak_day, y = peak_mw))+
geom_text(data = summary,
aes(x = peak_day, y = round(maxv, -2)*1.1),
label = glue("Peak {maxv} MW \n@ {peak_day}"))+
geom_point(data=summary,
aes(x = min_day, y = min_mw))+
geom_text(data = summary,
aes(x = min_day, y = round(minv, -2)),
label = glue("Minimum {minv} MW \n@ {min_day}"),
hjust = 0,
vjust = 0)
# Save the output ####
outputfigure <- paste0(outfigdir, "dc_r2_northeastern_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("dc_r2_northeastern_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("dc_r2_northeastern_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_dc_r2_northeastern_egtsle_2019" = summary))The 2019 electricity sale profile from EGAT to direct customer in PEA-R2 is illustrated in Figure 2.8).
Figure 2.8: EGAT electricity sale profile to direct customer in PEA-R2 in 2019.
2.2.3.3 The 2019 DC in in PEA R3 (Southern region) EGAT sale profiles
# Profile data ####
profile <-
read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
sheet = "Load Curve",
range = "C3:L17523"
) %>%
select(datetime = `Date/Time`, DCs_R3) %>%
mutate(date = date(datetime),
time = format(as.POSIXct(datetime),"%H:%M:%S"),
year = year(datetime),
month = month(datetime),
day = day(datetime)) %>%
select(datetime, date, time, year, month, day, DCs_R3) #%>% | datetime | date | time | year | month | day | DCs_R3 |
|---|---|---|---|---|---|---|
| 2019-01-01 00:00:00 | 2019-01-01 | 00:00:00 | 2019 | 1 | 1 | 17.170 |
| 2019-01-01 00:30:00 | 2019-01-01 | 00:30:00 | 2019 | 1 | 1 | 16.990 |
| 2019-01-01 01:00:00 | 2019-01-01 | 01:00:00 | 2019 | 1 | 1 | 16.455 |
| 2019-01-01 01:30:00 | 2019-01-01 | 01:30:00 | 2019 | 1 | 1 | 17.045 |
| 2019-01-01 02:00:00 | 2019-01-01 | 02:00:00 | 2019 | 1 | 1 | 16.760 |
| peak_day | min_day | peak_mw | min_mw | energy_gwh | load_factor |
|---|---|---|---|---|---|
| 2019-12-14 15:00:00 | 2019-03-30 14:30:00 | 253 | 0 | 419.8491 | 18.94% |
# Plot a profile ####
profile_plot <-
ggplot() +
geom_line(data=profile,
aes(x = datetime,
y = DCs_R3,
group = month,
color = as.factor(month)),
show.legend = FALSE) +
ThemeLine +
labs(x = NULL,
y = "EGAT sale to direct customers in PEA R3 (Southern region) (MW)")+
scale_x_datetime(breaks=date_breaks("1 month"),
labels=date_format("%b %y")) +
scale_y_continuous(breaks = seq(0, round(maxv,-2),100),
limits = c(0, round(maxv, -2))) +
scale_color_manual(values = linepalette1) +
geom_point(data=summary,
aes(x = peak_day, y = peak_mw))+
geom_text(data = summary,
aes(x = peak_day, y = round(maxv, -2)),
label = glue("Peak {maxv} MW \n@ {peak_day}"))+
geom_point(data=summary,
aes(x = min_day, y = min_mw))+
geom_text(data = summary,
aes(x = min_day, y = round(minv, -2)),
label = glue("Minimum {minv} MW \n@ {min_day}"),
hjust = 0,
vjust = 0)
# Save the output ####
outputfigure <- paste0(outfigdir, "dc_r3_southern_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("dc_r3_southern_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("dc_r3_southern_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_dc_r3_southern_egtsle_2019" = summary))The 2019 electricity sale profile from EGAT to direct customer in PEA-R3 is illustrated in Figure 2.9).
Figure 2.9: EGAT electricity sale profile to direct customer in PEA-R3 in 2019.
2.2.3.4 The 2019 DC in in PEA R4 (Northern region) EGAT sale profiles
# Profile data ####
profile <-
read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
sheet = "Load Curve",
range = "C3:M17523"
) %>%
select(datetime = `Date/Time`, DCs_R4) %>%
mutate(date = date(datetime),
time = format(as.POSIXct(datetime),"%H:%M:%S"),
year = year(datetime),
month = month(datetime),
day = day(datetime)) %>%
select(datetime, date, time, year, month, day, DCs_R4) #%>% | datetime | date | time | year | month | day | DCs_R4 |
|---|---|---|---|---|---|---|
| 2019-01-01 00:00:00 | 2019-01-01 | 00:00:00 | 2019 | 1 | 1 | 18.341 |
| 2019-01-01 00:30:00 | 2019-01-01 | 00:30:00 | 2019 | 1 | 1 | 20.824 |
| 2019-01-01 01:00:00 | 2019-01-01 | 01:00:00 | 2019 | 1 | 1 | 20.921 |
| 2019-01-01 01:30:00 | 2019-01-01 | 01:30:00 | 2019 | 1 | 1 | 28.174 |
| 2019-01-01 02:00:00 | 2019-01-01 | 02:00:00 | 2019 | 1 | 1 | 24.071 |
| peak_day | min_day | peak_mw | min_mw | energy_gwh | load_factor |
|---|---|---|---|---|---|
| 2019-02-02 16:00:00 | 2019-12-31 10:30:00 | 67 | 0 | 250.4462 | 42.67% |
# Plot a profile ####
profile_plot <-
ggplot() +
geom_line(data=profile,
aes(x = datetime,
y = DCs_R4,
group = month,
color = as.factor(month)),
show.legend = FALSE) +
ThemeLine +
labs(x = NULL,
y = "EGAT sale to direct customers in PEA R4 (Northern region) (MW)")+
scale_x_datetime(breaks=date_breaks("1 month"),
labels=date_format("%b %y")) +
scale_y_continuous(breaks = seq(0, round(maxv,-1),10),
limits = c(0, round(maxv, -1))) +
scale_color_manual(values = linepalette1) +
geom_point(data=summary,
aes(x = peak_day, y = peak_mw))+
geom_text(data = summary,
aes(x = peak_day, y = round(maxv, -1)),
label = glue("Peak {maxv} MW \n@ {peak_day}"),
hjust = 0.5) +
geom_point(data=summary,
aes(x = min_day, y = min_mw))+
geom_text(data = summary,
aes(x = min_day, y = round(minv, -1)),
label = glue("Minimum {minv} MW \n@ {min_day}"),
hjust = 1,
vjust = -0.5)
# Save the output ####
outputfigure <- paste0(outfigdir, "dc_r4_northern_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("dc_r4_northern_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("dc_r4_northern_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("dc_r4_northern_egtsle_2019" = summary))The 2019 electricity sale profile from EGAT to direct customer in PEA-R4 is illustrated in Figure 2.10).
Figure 2.10: EGAT electricity sale profile to direct customer in PEA-R4 in 2019.
2.2.3.5 The 2019 DC in in PEA (All regions) EGAT sale profiles
# Profile data ####
profile <-
read_excel("raw_data/raw_data_profiles/02_Hourly Sale_NetGen_2019.xlsx",
sheet = "Load Curve",
range = "C3:N17523"
) %>%
select(datetime = `Date/Time`, DCs) %>%
mutate(date = date(datetime),
time = format(as.POSIXct(datetime),"%H:%M:%S"),
year = year(datetime),
month = month(datetime),
day = day(datetime)) %>%
select(datetime, date, time, year, month, day, DCs) #%>% | datetime | date | time | year | month | day | DCs |
|---|---|---|---|---|---|---|
| 2019-01-01 00:00:00 | 2019-01-01 | 00:00:00 | 2019 | 1 | 1 | 282.674 |
| 2019-01-01 00:30:00 | 2019-01-01 | 00:30:00 | 2019 | 1 | 1 | 315.253 |
| 2019-01-01 01:00:00 | 2019-01-01 | 01:00:00 | 2019 | 1 | 1 | 299.744 |
| 2019-01-01 01:30:00 | 2019-01-01 | 01:30:00 | 2019 | 1 | 1 | 311.689 |
| 2019-01-01 02:00:00 | 2019-01-01 | 02:00:00 | 2019 | 1 | 1 | 287.727 |
| peak_day | min_day | peak_mw | min_mw | energy_gwh | load_factor |
|---|---|---|---|---|---|
| 2019-12-14 10:00:00 | 2019-07-10 16:30:00 | 1043 | 111 | 3977.771 | 43.54% |
# Plot a profile ####
profile_plot <-
ggplot() +
geom_line(data=profile,
aes(x = datetime,
y = DCs,
group = month,
color = as.factor(month)),
show.legend = FALSE) +
ThemeLine +
labs(x = NULL,
y = "EGAT sale to direct customers in PEA (All regions) (MW)")+
scale_x_datetime(breaks=date_breaks("1 month"),
labels=date_format("%b %y")) +
scale_y_continuous(breaks = seq(0, round(maxv,-2)*1.2,100),
limits = c(0, round(maxv, -2)*1.2)) +
scale_color_manual(values = linepalette1) +
geom_point(data=summary,
aes(x = peak_day, y = peak_mw))+
geom_text(data = summary,
aes(x = peak_day, y = round(maxv, -2)*1.2),
label = glue("Peak {maxv} MW \n@ {peak_day}"),
hjust = 0.5,
vjust = 1.5) +
geom_point(data=summary,
aes(x = min_day, y = min_mw))+
geom_text(data = summary,
aes(x = min_day, y = round(minv, -2)),
label = glue("Minimum {minv} MW \n@ {min_day}"),
# hjust = 0,
vjust = 1)
# Save the output ####
outputfigure <- paste0(outfigdir, "dc_allregions_egtsle_2019.png")
ggsave(profile_plot, file = outputfigure, dpi = 150, width = 15, height = 5, units = "in", limitsize = FALSE)
profiledata <- c(profiledata, list("dc_allregions_egtsle_2019" = profile))
profilefigure <- c(profilefigure, list("dc_allregions_egtsle_2019" = profile_plot))
summarydata <- c(summarydata, list("sum_dc_allregions_egtsle_2019" = summary))The 2019 electricity sale profile from EGAT to direct customer in PEA (all regions) is illustrated in Figure 2.11).
Figure 2.11: EGAT electricity sale profile to direct customer in PEA (all regions) in 2019.
2.2.4 The 2019 PEA R1 & DC R1 (Central region)EGAT electrity sale profiles
The electricity profile
\[\begin{equation} $Prf_{r,t,h}=\ Prf_{PEA,t,h} + Prf_{DC,t,h}$ \tag{2.3} \end{equation}\]
Where, \(Prf_{r,t,h}\) denotes an calculated profile in region \(r\), year \(t\), and time \(h\) (MW).
\(Prf_{PEA,t,h}\) denotes a profile in PEA from each region in year \(t\) at time \(h\) (MW).
\(Prf_{DC,t,h}\) denotes a profile from direct customer in each PEA region in year \(t\) at time \(h\) (MW).